package hu.plusone.eregister.dao;

import hu.plusone.eregister.model.Nursery;
import java.util.Collection;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

public interface NurseryDao extends JpaRepository<Nursery, Long>, JpaSpecificationExecutor<Nursery> {
    
    @Query("SELECT nurs FROM Nursery nurs INNER JOIN nurs.children child WHERE child.id = :childId")
    Collection<Nursery> findAllByChildId(@Param("childId") long childId);
}
